<template>
  <div ref="numDom">{{ num }}</div>
  <button @click="btnClick">修改num</button>
  <Son ref="sonCom"></Son>
  <button @click="btnClick2">获取son组件实例对象</button>
</template>
<script>
import { ref } from 'vue'
import Son from './components/Son.vue'
export default {
  components: {
    Son
  },
  setup () {
    const num = ref(0)
    const numDom = ref(null)
    function btnClick () {
      console.log(numDom.value)
      num.value++
    }

    // 获取组件实例对象
    const sonCom = ref(null)
    function btnClick2 () {
      console.log(sonCom.value)
    }
    return { num, btnClick, numDom, btnClick2, sonCom }
  }
}
</script>
<style></style>
